package com.qianfeng.job;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Date;

public class TestJob2 {


    public static void main(String[] args) throws SchedulerException {

        JobDetail jobDetail = JobBuilder.newJob(HelloJob.class).build();

        Date startTime = new Date();

        startTime.setTime(startTime.getTime()+5000);

        Date endTime = new Date();
        endTime.setTime(endTime.getTime()+10000);

        Trigger trigger = TriggerBuilder.newTrigger().withIdentity("t1", "tg1")
                .startNow()
                .startAt(startTime)
                .endAt(endTime)
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(1000).repeatForever())
                .build();

        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        scheduler.scheduleJob(jobDetail,trigger);

        scheduler.start();
    }
}
